package model

import (
	"crypto/md5"
	"fmt"
)

type User struct {
	Id        int64  `json:"id" form:"id" query:"id" goblet:"id" xorm:"pk autoincr"`
	Username  string `json:"username" form:"username" query:"username" goblet:"username"`
	Password  string `json:"password" form:"password" query:"password" goblet:"password"`
	Privilege int    `json:"privilege" form:"privilege" query:"privilege" goblet:"privilege"`
}

func (u *User) EncryptPassword(salt string) {
	enc := md5.New()
	enc.Write([]byte(u.Password))
	enc.Write([]byte(salt))
	u.Password = fmt.Sprintf("%x", enc.Sum(nil))
}
